﻿using System;
using Mvc.Validation;

namespace ValidationSample.Models
{
    public class LoginNameValidator : IValidator
    {
        public bool IsValid(object value)
        {
            if (!(value is string))
                throw new ArgumentException("Must be used with string type");

            // For simplicity, I do a quick check here.  In real apps,
            // you might look for existing login name in the database...
            return (string)value != "buunguyen"; 
        }
    }
}
